﻿using System.Xml;
using AutoTaskSchedule.Core.Common;

namespace AutoTaskSchedule.Core.Extensions
{
    public static class XmlNodeExtension
    {
        public static T TryGet<T>(this XmlNode node, string attributeName)
        {
            if (node == null || node.Attributes == null) return default(T);
            if (node.Attributes[attributeName] == null) return default(T);

            return (T) Utils.ChangeType(node.Attributes[attributeName].Value, typeof(T));
        }
    }
}